uniform vec3 fg; //new color
uniform sampler2D texture; //texture to change
 
void main() {
  //vec2 coords = (gl_FragCoord.xy / resolution.xy); //coordinates
  vec2 coords = gl_TexCoord[0].xy;
  vec4 normalColor = texture2D(texture, coords).rgba; //original color
  
  if ((normalColor.a != 0) && (normalColor.r == normalColor.g) && (normalColor.g == normalColor.b)) {
    //it's gray, change it
    float a = .392f;//float(100/255);
    float r = fg.r * a + normalColor.r * (1 - a);
    float g = fg.g * a + normalColor.g * (1 - a);
    float b = fg.b * a + normalColor.b * (1 - a);
    gl_FragColor = vec4(r, g, b, normalColor.a);
  } else
    gl_FragColor = normalColor;
}